
#include "IDuplicateState.h"


IDuplicateState::IDuplicateState() :m_byState((int8_t)EDuplicateState::EDuplicateState_None)
{
	m_setState.clear();
}

IDuplicateState::~IDuplicateState()
{
	m_byState = (int8_t)EDuplicateState::EDuplicateState_None;
	m_setState.clear();
}

//获取副本状态
int8_t IDuplicateState::GetDuplicateState()
{
	return m_byState;
}
//设置副本状态
bool IDuplicateState::SetDuplicateState(int8_t byState)
{
	if (m_byState == byState)
	{
		return false;
	}
	SET_INT32::const_iterator iter = m_setState.find(byState);
	if (iter == m_setState.end())
	{
		return false;
	}
	//设置新状态
	m_byState = byState;
	//状态改变
	OnStateChanged(m_byState);

	return true;
}

//增加状态
void IDuplicateState::AddDuplicateState(int8_t byState)
{
	m_setState.insert(byState);
}
//删除状态
void IDuplicateState::DelDuplicateState(int8_t byState)
{
	m_setState.erase(byState);
}
//清空状态
void IDuplicateState::ClearDuplicateState()
{
	m_setState.clear();
}
//状态改变
void IDuplicateState::OnStateChanged(int8_t byNewState)
{
	switch (byNewState)
	{
	case (int8_t)EDuplicateState::EDuplicateState_Ready:
		{
			OnDuplicateState_Ready();
		}
		break;
	case (int8_t)EDuplicateState::EDuplicateState_Begin:
		{
			OnDuplicateState_Begin();
		}
		break;
	case (int8_t)EDuplicateState::EDuplicateState_Finish:
		{
			OnDuplicateState_Finish();
		}
		break;
	case (int8_t)EDuplicateState::EDuplicateState_Flop:
		{
			OnDuplicateState_Flop();
		}
		break;
	case (int8_t)EDuplicateState::EDuplicateState_Clean:
		{
			OnDuplicateState_Clean();
		}
		break;
	case (int8_t)EDuplicateState::EDuplicateState_Destory:
		{
			OnDuplicateState_Destory();
		}
		break;
	default:
		break;
	}
}